<?php
    //include_once 'init.php';
    //


    if(!empty($_POST)){
         $_POST['power']=implode(',',$_POST['power']);
         $result=edit($c,$_POST['id'],$_POST);
         if($result>0){
                echo '<script>alert("角色修改成功");location.href="index.php?c=role&a=list&admin=1";</script>';die;
            }else{
                echo '<script>alert("角色修改失败");history.go(-1);</script>';die;
            }
    }
    $data=array();

    $id=$_GET['id'];
    $data=getSelectOne($c,'id='.$id);
    $power=explode(',',$data['power']);

    $parent=getSelect('power','*','pid = 0');
    $child=getSelect('power','*','pid != 0');

include(VIEW_PATH.$admin.'layout.html');
?>